import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RolemenuVO, RolemenuForm, RolemenuQuery } from '@/api/system/roleMenu/types';

/**
 * 查询App角色和菜单关联列表
 * @param query
 * @returns {*}
 */

export const listRolemenu = (query?: RolemenuQuery): AxiosPromise<RolemenuVO[]> => {
  return request({
    url: '/system/roleMenu/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询App角色和菜单关联详细
 * @param roleId
 */
export const getRolemenu = (roleId: string | number): AxiosPromise<RolemenuVO> => {
  return request({
    url: '/system/roleMenu/' + roleId,
    method: 'get'
  });
};

/**
 * 新增App角色和菜单关联
 * @param data
 */
export const addRolemenu = (data: RolemenuForm) => {
  return request({
    url: '/system/roleMenu',
    method: 'post',
    data: data
  });
};

/**
 * 修改App角色和菜单关联
 * @param data
 */
export const updateRolemenu = (data: RolemenuForm) => {
  return request({
    url: '/system/roleMenu',
    method: 'put',
    data: data
  });
};

/**
 * 删除App角色和菜单关联
 * @param roleId
 */
export const delRolemenu = (roleId: string | number | Array<string | number>) => {
  return request({
    url: '/system/roleMenu/' + roleId,
    method: 'delete'
  });
};
